#ifndef CTCLIENTSOCKET_H
#define CTCLIENTSOCKET_H

//#include <QObject>
#include "precomp.h"

class CTClientSocket : public QObject, public QRunnable
{
    Q_OBJECT
public:
    explicit CTClientSocket(QObject *parent = nullptr);
    ~CTClientSocket();
    void setServerAddress(const QString &address);
    void setServerPort(int port);
    void setSendMsg(QString sendMsg);
    void setMsgFlag(QString msgFlag,QString requestId);
    void setRequestParam(QString reqParam);

    QString getRequestParam();
    void run() override;
signals:
    void dataSocketReceived(QByteArray data, QString requestId);
public slots:

    void startConnection();
    void sendMessage();
    void handleDataReceived();
    void socketError(QAbstractSocket::SocketError error);
private:
    QTcpSocket *m_tcpSocket;
    QString m_serverAddress,m_sendMsg,m_flag,m_requestId,m_reqParam;
    int m_serverPort;
    QByteArray m_recvBuffer;
};


#endif // CTCLIENTSOCKET_H
